package com.yc.star.booksystem.config;

import com.yc.star.booksystem.model.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@Slf4j
@ResponseBody
@ControllerAdvice
public class ErrorHandler {

    @ExceptionHandler
    public Result handler(Exception e) {
        log.error("捕获异常："+e);
        return Result.fail("发生内部错误，请联系管理员！");
    }

}
